
#include <iostream>
#include "Header.h"

#pragma comment(lib, "dll_export.lib")
int main(int argc, char* argv[])
{
	list<int> input;
	list<char> type_figure;
	if (argc < 2)
	{
		char data[100][4];
		char figures[] = { "TRC" };
		argc = 20;
		int index_data = 0;
		for (int q = 0; figures[q] != '\0'; q++)
		{
			type_figure.push_back(figures[q]);
			switch (figures[q])
			{
			case 'T':
				argc = 6;

				break;
			case 'R':
				argc = 8;
				break;

			case 'C':
				argc = 3;
				break;
			}
			for (int i = 0; i < argc; i++)
			{
				int modif_int_char = (rand() + 1) % 100;
				char *c = new char[100];
				int v = 0;
				while (modif_int_char > 9)
				{
					c[v++] = (modif_int_char % 10) + '0';
					modif_int_char = modif_int_char / 10;
				}
				c[v++] = modif_int_char + '0';
				c[v] = '\0';
				char t;
				for (int modif_int_char = 0; modif_int_char <= v / 2 - 1; modif_int_char++)
				{
					t = c[modif_int_char];
					c[modif_int_char] = c[v - 1 - modif_int_char];
					c[v - 1 - modif_int_char] = t;
				}
				for (int k = 0; *c != '\0'; k++)
				{
					data[index_data][k] = *c;
					c++;
				}
				index_data++;
			}
		}
		for (int i = 0, t = 0; i < index_data; t++)
		{
			if (figures[t] == 'R')
			{
				int size = i + 8;
				while (i < size)
				{
					if (i % 2 == 0)
					{
						input.push_back(atoi(&data[i][0]));
					}
					else
					{
						input.push_back(atoi(&data[i][0]));
					}
					i++;
				}
			}
			if (figures[t] == 'T')
			{
				int size = i + 6;
				while (i < size)
				{
					if (i % 2 == 0)
					{
						input.push_back(atoi(&data[i][0]));
					}
					else
					{
						input.push_back(atoi(&data[i][0]));
					}

					i++;
				}
			}
			if (figures[t] == 'C')
			{
				input.push_back(atoi(&data[i][0])); //x

				i++;

				input.push_back(atoi(&data[i][0])); //y

				i++;

				input.push_back(atoi(&data[i][0])); //r
				i++;
			}
		}
	}
	else for (int i = 2, number_inputs = argc; i < argc + 2; i++)
	{
		if (argv[i] == "R")
		{
			type_figure.push_back(*argv[i]);
			i++;
			int size = i + 8;
			while (i != size)
			{
				if (i % 2 == 0)
				{
					input.push_back(atoi(argv[i]));;
				}
				else
				{
					input.push_back(atoi(argv[i]));;
				}
				i++;
			}
		}
		if (argv[i] == "T")
		{
			type_figure.push_back(*argv[i]);
			i++;
			int size = i + 6;
			while (i != size)
			{
				if (i % 2 == 0)
				{
					input.push_back(atoi(argv[i]));;
				}
				else
				{
					input.push_back(atoi(argv[i]));;
				}

				i++;
			}
		}
		if (argv[i] == "C")
		{
			type_figure.push_back(*argv[i]);
			i++;
			input.push_back(atoi(argv[i])); //x
			i++;
			input.push_back(atoi(argv[i])); //y
			i++;
			input.push_back(atoi(argv[i])); //r
		}
	}
	Make_Figure *myfigure = new Make_Figure();
	//printf("create new figure? (yes or no)\n");
    char trueOrfalse[4] = { "yes" };
	//scanf_s("%s", trueOrfalse, 4);
	if (*trueOrfalse == *"yes")
	{
		for (auto iter = input.begin(); iter != input.end(); iter++)
		{
			Figure *x_figure;
			for (auto iter_figure = type_figure.begin(); iter_figure != type_figure.end(); iter_figure++)
			{
				if (*iter_figure == 'T')
				{
					std::list<int> T_x;
					std::list<int> T_y;
					int i = 0;
					for (; i != 3; i++, iter++)
					{
						T_x.push_back(*iter);
						iter++;
						T_y.push_back(*iter);
					}
					x_figure = new triangle(T_x, T_y);
					myfigure->push_back(x_figure);
				}
				if (*iter_figure == 'R')
				{
					list<int> C_x;
					list<int> C_y;
					int i = 0;
					for (; i != 4; i++, iter++)
					{
						C_x.push_back(*iter);
						iter++;
						C_y.push_back(*iter);
					}
					x_figure = new rectangle(C_x, C_y);
					myfigure->push_back(x_figure);
				}
				if (*iter_figure == 'C')
				{
					int x, y, r;
					for (; ; iter++)
					{
						x = *iter;
						iter++;
						y = *iter;
						iter++;
						r = *iter;
						break;
					}
					x_figure = new circle(&x, &y, &r);
					myfigure->push_back(x_figure);
				}
			}
		}
	}
    /*int a = 1;int b = 1;int c = 1;
	printf("Input number figure");
	std::cin >> a;
	printf("Input X");
	std::cin >> b;
	printf("Input Y");
	std::cin >> c;
	myfigure->load_file(*myfigure);
    myfigure->move_figure(&a, &b, &c);*/
	myfigure->writeFile("testmydll");
    return 0;
}